// src/api/mock.js
import Mock from 'mockjs'
import homeApi from './mockData/home'
import deviceApi from './mockData/device'

// 设置一下模拟返回数据时间
Mock.setup({
  timeout: '100-200'
})

// 方式一:无参数
Mock.mock(
  "/user/userinfo",
  'get',
  (req) => {
      console.log(req);
      return {
          username: '名字',
          type: '类型'
      }
  }
)

// 方式二:有参数
Mock.mock(
  /\/account.*/,
  'get',
  (req) => {
      console.log(req);
      return {
          username: 'abc',
          type: '123'
      }
  }
)


// 拦截请求
Mock.mock('/home/getData', homeApi.getHomeData)
Mock.mock('/home/getDeviceOne', deviceApi.getDeviceOne)
Mock.mock('/home/getDeviceTwo', deviceApi.getDeviceTwo)
Mock.mock('/home/getDeviceThree', deviceApi.getDeviceThree)
Mock.mock('/home/getDeviceAllData', deviceApi.getDeviceAllData)